<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"
   "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
  <title>
    <% if @document -%>
        <%= @document.title %>
    <% else -%>
      Document <%= controller.action_name %>
    <% end %>
  </title>
  <%= stylesheet_link_tag 'scaffold' %>
  <%= stylesheet_link_tag 'cdocs' %>
</head>
  <body id="docs">
  <div id="banner">Document Library</div>
  <div id="columns">
    <div id="side">
        <% if logged_in? -%>
            Logged in as <%= current_user.login %> <br/>
            <%= render(:partial => "account/logout") %>
            <%= link_to 'Tasks',   :controller => :tasks %><br/>
        <% else %>
            <%= render(:partial => "account/login") %>
            <%= link_to 'Sign Up', :controller => :account, :action => :signup %> <br/>
        <% end %>    
        <%= link_to 'Search',  :controller => :info %> <br/>
    </div>
    <% if @document && @document.comments.count > 0  -%>
    <div id="comments">
        <h3>Comments</h3>
        <%= render(:partial => "comment/comments") %>
    </div>
    <% end %>
    <% if @document && logged_in? && @document.document_state_id == 3  && @document.user != current_user -%>
    <div id="basevotebox">
        <% if @document.voted_by_user?(current_user) %>
        <h3> You have already voted </h3>
        <% else %>
        <h3>Cast Your Vote</h3>
        <%= render(:partial => "vote/votebox", :locals => {:document=> @document}) %>
        <% end %>
    </div>
    <% end %>
    <div id="main">
        <p style="color: green"><%= flash[:notice] %></p>
        <%= yield :layout %>
    </div>
    
    <% if @document && @document.document_state_id == 0  -%>
    <div id="votebox">
        <%= render(:partial => "vote/votebox") %>
    </div>
    <% end %>
    
  </div>
  </body>
</html>